package com.emergency.examine.dao;

import com.emergency.examine.domain.ExamScore;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface ExamScoreDao extends JpaRepository<ExamScore, Long>, JpaSpecificationExecutor<ExamScore> {
    @Modifying
    @Transactional
    @Query(value = "delete FROM ex_exam_score WHERE staff_id = ? ", nativeQuery = true)
    void deleteByExamStaffId(Long staffId);

    @Query("select es from ExamScore es where examStaff.id = :staffId")
    List<ExamScore> findAllByExamStaff(Long staffId);

}
